package emulator.unittest.hardware.nmos6502.timing;

import static org.junit.Assert.*;

import org.junit.Before;
import org.junit.Test;

import emulator.EmulatorException;

public class ZeroPageTest {

	TimingTestBase test_base = null;
	
	@Before
	public void setUp() throws Exception {
		test_base = new TimingTestBase();
	}
	
	@Test
	public void testADC() throws EmulatorException
	{
		assertEquals(3, getCycles(0x65));
	}
	
	@Test
	public void testAND() throws EmulatorException
	{
		assertEquals(3, getCycles(0x25));
	}
	
	@Test
	public void testASL() throws EmulatorException
	{
		assertEquals(5, getCycles(0x06));
	}
	
	@Test
	public void testBIT() throws EmulatorException
	{
		assertEquals(3, getCycles(0x24));
	}
	
	@Test
	public void testCMP() throws EmulatorException
	{
		assertEquals(3, getCycles(0xC5));
	}
	
	@Test
	public void testCPX() throws EmulatorException
	{
		assertEquals(3, getCycles(0xE4));
	}
	
	@Test
	public void testCPY() throws EmulatorException
	{
		assertEquals(3, getCycles(0xC4));
	}
	
	@Test
	public void testDEC() throws EmulatorException
	{
		assertEquals(5, getCycles(0xC6));
	}
	
	@Test
	public void testEOR() throws EmulatorException
	{
		assertEquals(3, getCycles(0x45));
	}
	
	@Test
	public void testINC() throws EmulatorException
	{
		assertEquals(5, getCycles(0xE6));
	}
	
	@Test
	public void testLDA() throws EmulatorException
	{
		assertEquals(3, getCycles(0xA5));
	}
	
	@Test
	public void testLDX() throws EmulatorException
	{
		assertEquals(3, getCycles(0xA6));
	}
	
	@Test
	public void testLDY() throws EmulatorException
	{
		assertEquals(3, getCycles(0xA4));
	}
	
	@Test
	public void testLSR() throws EmulatorException
	{
		assertEquals(5, getCycles(0x46));
	}
	
	@Test
	public void testORA() throws EmulatorException
	{
		assertEquals(3, getCycles(0x05));
	}
	
	@Test
	public void testROL() throws EmulatorException
	{
		assertEquals(5, getCycles(0x26));
	}
	
	@Test
	public void testROR() throws EmulatorException
	{
		assertEquals(5, getCycles(0x66));
	}
	
	@Test
	public void testSBC() throws EmulatorException
	{
		assertEquals(3, getCycles(0xE5));
	}
	
	@Test
	public void testSTA() throws EmulatorException
	{
		assertEquals(3, getCycles(0x85));
	}
	
	@Test
	public void testSTX() throws EmulatorException
	{
		assertEquals(3, getCycles(0x86));
	}
	
	@Test
	public void testSTY() throws EmulatorException
	{
		assertEquals(3, getCycles(0x84));
	}
	
	private int getCycles(int opcode) throws EmulatorException
	{
		test_base.setCommand(0, opcode, 0x44, 0);
		test_base.execute();
		return test_base.getElapsedCycles();
	}
}
